import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AdmBookApplyVO, AdmBookApplyForm, AdmBookApplyQuery } from '@/api/general/administration/book/apply/types';

/**
 * 查询图书申购列表
 * @param query
 * @returns {*}
 */

export const listAdmBookApply = (query?: AdmBookApplyQuery): AxiosPromise<AdmBookApplyVO[]> => {
  return request({
    url: '/system/admBookApply/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询图书申购详细
 * @param id
 */
export const getAdmBookApply = (id: string | number): AxiosPromise<AdmBookApplyVO> => {
  return request({
    url: '/system/admBookApply/' + id,
    method: 'get'
  });
};

/**
 * 新增图书申购
 * @param data
 */
export const addAdmBookApply = (data: AdmBookApplyForm) => {
  return request({
    url: '/system/admBookApply',
    method: 'post',
    data: data
  });
};

/**
 * 修改图书申购
 * @param data
 */
export const updateAdmBookApply = (data: AdmBookApplyForm) => {
  return request({
    url: '/system/admBookApply',
    method: 'put',
    data: data
  });
};

/**
 * 删除图书申购
 * @param id
 */
export const delAdmBookApply = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/admBookApply/' + id,
    method: 'delete'
  });
};

/**
 * 批量添加图书
 * @param data 批量添加图书的请求参数
 * @returns
 */
export function batchAddBooks(data: any) {
  return request({
    url: '/system/admBookApply/batchAdd',
    method: 'post',
    data
  })
}
